<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: 'app',
  computed: {
    ...mapState({
      token: state => state.auth.token,
      scroll: state => state.index.scrollTop
    })
  },
  watch: {
    token (val, oldVal) {
      if (val === '') {
        this.$store.dispatch('auth/getToken')
      } else {
        this.$store.dispatch('auth/getAuthList', {getServiceAuth: true})
      }
    }
  },
  created () {
    this.$store.dispatch('auth/getToken')
  },
  mounted () {
    window.addEventListener('scroll', this.getScrollTop)
  },
  methods: {
    getScrollTop () {
      if (document) {
        this.$store.dispatch('home/scorollTop')
      }
    }
  }
}
</script>

<style lang="scss">
@import './assets/scss/base.scss';

#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: $c-t-main;
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-weight: normal;
  list-style: none;
  outline: none;
  text-decoration: none;
  height: 100%;
  a {
    /*<!--color: $c-t-white;-->*/
    text-decoration: none;
  }
  ul li {
    list-style-type: none;
    margin: 0;
  }
  /*列表分页位置*/
  .pagination {
    margin: 20px 0;
    text-align: right;
  }
  /*列表按钮布局*/
  .el-button, .el-button + .el-button {
    margin: 0 5px 5px 0;
  }
  .mb-20 {
    margin-bottom: 20px;
  }
  .w500 {
    width: 500px;
  }
  .w100 {
    width: 100px;
  }
  .el-tree {
    border: 1px #d1dbe5 solid;
    .el-tree-node__content {
      height: 36px;
      line-height: 36px;
    }
  }
}
</style>
